package com.ssy.lingxi.after.sale.entity;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.ssy.lingxi.after.sale.handler.converter.JpaJsonToReplaceReceiveGoodsBOConverter;
import com.ssy.lingxi.after.sale.model.bo.ReplaceReceiveGoodsBO;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Set;

/**
 * 售后换货发货
 * @author 伍将
 * @date 2020/9/17
 * @version 2.0.0
 */
@Entity
@Table(schema = "public", name = "as_replace_delivery_goods",
        indexes = {@Index(name = "as_replace_delivery_goods_replace_id_idx", columnList = "replaceId"),
                @Index(name = "as_replace_delivery_goods_replace_delivery_type_idx", columnList = "replaceDeliveryType"),
                @Index(name = "as_replace_delivery_goods_batch_no_idx", columnList = "batchNo"),
                @Index(name = "as_replace_delivery_goods_storage_id_idx", columnList = "storageId"),
                @Index(name = "as_replace_delivery_goods_status_idx", columnList = "status")})
public class ReplaceDeliveryGoodsDO implements Serializable {
    private static final long serialVersionUID = 8732432780369746311L;

    /**
     * id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "replace_delivery_goods_seq")
    @SequenceGenerator(sequenceName = "as_replace_delivery_goods_seq", name = "replace_delivery_goods_seq", allocationSize = 1)
    private Long id;

    /**
     * 换货id
     */
    @Column(columnDefinition = "int8")
    private Long replaceId;

    /**
     * 换货发货类型 0-所有 1-退货 2-换货
     * ReplaceDeliveryGoodsTypeEnum
     */
    @Column(columnDefinition = "int")
    private Integer replaceDeliveryType;

    /**
     * 批次号
     */
    @Column(columnDefinition = "int8")
    private Integer batchNo;

    /**
     * 发货单号
     */
    @Column(columnDefinition = "varchar(50)")
    private String deliveryOrderNo;

    /**
     * 发货时间
     */
    @Column(columnDefinition = "int8")
    private Long deliveryTime;

    /**
     * 物流id
     */
    @Column(columnDefinition = "int8")
    private Long logisticsId;

    /**
     * 物流单号
     */
    @Column(columnDefinition = "varchar(50)")
    private String logisticsOrderNo;

    /**
     * 物流公司
     */
    @Column(columnDefinition = "varchar(50)")
    private String logisticsName;

    /**
     * 入库单id
     */
    @Column(columnDefinition = "int8")
    private Long storageId;

    /**
     * 入库单号
     */
    @Column(columnDefinition = "varchar(50)")
    private String storageNo;

    /**
     * 入库时间
     */
    @Column(columnDefinition = "int8")
    private Long storageTime;

    /**
     * 内部状态 1-未确认退货发货 2-已确认退货发货 3-已确认退货收货 4-确认退货回单
     */
    @Column(columnDefinition = "int")
    private Integer status;

    /**
     * 创建时间
     */
    @Column(columnDefinition = "int8")
    private Long createTime;

    /**
     * 更新时间
     */
    @Column(columnDefinition = "int8")
    private Long updateTime;

    /**
     * 退货发货商品明细
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "deliveryGoods", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private Set<ReplaceDeliveryGoodsDetailDO> detailList;

    /**
     * 发货地址（融合版本新增）
     */
    @Column(columnDefinition = "varchar(200)")
    private String deliveryAddress;

    /**
     * 单据摘要
     */
    @Column(columnDefinition = "varchar(60)")
    private String orderAbstract;

    /**
     * 备注
     */
    @Column(columnDefinition = "varchar(160)")
    private String remark;

    /**
     * 对应仓库
     */
    @Column(columnDefinition = "varchar(30)")
    private String inventoryName;

    /**
     * 对应仓库人员
     */
    @Column(columnDefinition = "varchar(12)")
    private String inventoryRole;

    /**
     * 换货：退货收货单信息
     */
    @Convert(converter = JpaJsonToReplaceReceiveGoodsBOConverter.class)
    @Column(columnDefinition = "jsonb")
    private ReplaceReceiveGoodsBO replaceReceiveGoodsBO;

    public Long getStorageId() {
        return storageId;
    }

    public void setStorageId(Long storageId) {
        this.storageId = storageId;
    }

    public Long getLogisticsId() {
        return logisticsId;
    }

    public void setLogisticsId(Long logisticsId) {
        this.logisticsId = logisticsId;
    }

    public Integer getReplaceDeliveryType() {
        return replaceDeliveryType;
    }

    public void setReplaceDeliveryType(Integer replaceDeliveryType) {
        this.replaceDeliveryType = replaceDeliveryType;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getReplaceId() {
        return replaceId;
    }

    public void setReplaceId(Long replaceId) {
        this.replaceId = replaceId;
    }

    public Integer getBatchNo() {
        return batchNo;
    }

    public void setBatchNo(Integer batchNo) {
        this.batchNo = batchNo;
    }

    public String getDeliveryOrderNo() {
        return deliveryOrderNo;
    }

    public void setDeliveryOrderNo(String deliveryOrderNo) {
        this.deliveryOrderNo = deliveryOrderNo;
    }

    public Long getDeliveryTime() {
        return deliveryTime;
    }

    public void setDeliveryTime(Long deliveryTime) {
        this.deliveryTime = deliveryTime;
    }

    public String getLogisticsOrderNo() {
        return logisticsOrderNo;
    }

    public void setLogisticsOrderNo(String logisticsOrderNo) {
        this.logisticsOrderNo = logisticsOrderNo;
    }

    public String getLogisticsName() {
        return logisticsName;
    }

    public void setLogisticsName(String logisticsName) {
        this.logisticsName = logisticsName;
    }

    public String getStorageNo() {
        return storageNo;
    }

    public void setStorageNo(String storageNo) {
        this.storageNo = storageNo;
    }

    public Long getStorageTime() {
        return storageTime;
    }

    public void setStorageTime(Long storageTime) {
        this.storageTime = storageTime;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public Long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
    }

    public Set<ReplaceDeliveryGoodsDetailDO> getDetailList() {
        return detailList;
    }

    public void setDetailList(Set<ReplaceDeliveryGoodsDetailDO> detailList) {
        this.detailList = detailList;
    }

    public String getDeliveryAddress() {
        return deliveryAddress;
    }

    public void setDeliveryAddress(String deliveryAddress) {
        this.deliveryAddress = deliveryAddress;
    }

    public String getOrderAbstract() {
        return orderAbstract;
    }

    public void setOrderAbstract(String orderAbstract) {
        this.orderAbstract = orderAbstract;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getInventoryName() {
        return inventoryName;
    }

    public void setInventoryName(String inventoryName) {
        this.inventoryName = inventoryName;
    }

    public String getInventoryRole() {
        return inventoryRole;
    }

    public void setInventoryRole(String inventoryRole) {
        this.inventoryRole = inventoryRole;
    }

    public ReplaceReceiveGoodsBO getReplaceReceiveGoodsBO() {
        return replaceReceiveGoodsBO;
    }

    public void setReplaceReceiveGoodsBO(ReplaceReceiveGoodsBO replaceReceiveGoodsBO) {
        this.replaceReceiveGoodsBO = replaceReceiveGoodsBO;
    }
}
